<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>商家注册</title>
<script src="../../js/jquery-1.6.js" type="text/javascript" ></script>
<script src="../../js/jquery.form.js" type="text/javascript"></script>
<script src="../../js/json2.js" type="text/javascript"></script>
<script src="../../js/ac.js" type="text/javascript"></script>
<script language="javascript" type="text/javascript">
	$(document).ready(function(){
		alert("ok");
		//提交注册
		$("#regbtn").click(function(){			
			var options = { 
				url: "ShopReg.action", 
				dataType: 'json', 
				success: function(data) {				 
					$("#msg_reg").html(data.msg);
			   }				
			}; 			
			$("#regform").ajaxSubmit(options);			
		});
		//验证name有效性
		$("#name").blur(function(){			
			$.ajax({
				url:"Validate_AdminName.action",//ShopReg!validateShopName.action访问方法的形式
				dataType:'json',
				data:{
					'shop.adminName':$(this).val(),
				},
				success:function(data){						
					if(data.state=="0")
						$("#msg_name").html(data.msg);
					else
						$("#msg_name").html("");						
				}
			});				
		});
		//验证shopName有效性
		$("#shopname").blur(function(){			
			$.ajax({
				url:"Validate_ShopName.action",//也可以ShopReg!validateShopName.action访问方法的形式
				dataType:'json',
				data:{
					'shop.shopName':$(this).val(),
				},
				success:function(data){	
					if(data.state=="0")
						$("#msg_shopname").html(data.msg);
					else
						$("#msg_shopname").html("");
				}
			});				
		});
		//
		$("#password").blur(function(){			
						
		});
		//获取商铺列表
		$("#shoplist").click(function(e){
			e.preventDefault();
			$.ajax({
				url:"Shop_list.action",//也可以ShopReg!validateShopName.action访问方法的形式
				dataType:'json',
				data:{
					'shop.shopName':$(this).val(),
				},
				success:function(data){	
					alert(JSON.stringify(data));
				}
			});	
			
		});
		//查看商铺信息
		$("#shopview").click(function(e){
			e.preventDefault();
			$.ajax({
				url:"Shop_view.action",//也可以ShopReg!validateShopName.action访问方法的形式
				dataType:'json',
				data:{
					'shopId':'1',
				},
				success:function(data){	
					alert(data.shop.shopName);
				}
			});	
			
		});
		
	});	
	function testcallback(data)
	{
		alert(data.msg);
	}
</script>
</head>
<body>
<form id="regform" name="refform">
会员名称:<input type="text" id="name" name="shop.adminName"/><span id="msg_name"></span><br/>
密码:<input type="text" id="password" name="shop.password"/><span id="msg_password"></span><br/>
公司名称:<input type="text" id="shopname" name="shop.shopName"/><span id="msg_shopname"></span><br/>
<input type="button" id="regbtn" value="reg"/><span id="msg_reg"></span>
</form>
<a href="#" id="shoplist">获取商铺列表</a><br/>
<a href="#" id="shopview">查看商铺信息</a>
</body>
</html>